## 20ms 3072KB 9Min
a,b,d=[int(i) for i in input().split()]
c=a+b
ans=[]
remain=0 #经过while后，最终余数temp必不为零
while c:
    c,remain=divmod(c,d)
    ans.append(remain)

print(*ans[::-1],sep='')if remain else print('0')